package org.jeeasy.generate.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeeasy.common.core.domain.vo.R;
import org.jeeasy.generate.domain.dto.NewGeneratorDTO;
import org.jeeasy.generate.service.GeneratorService;
import org.jeeasy.generate.service.vo.GenResultVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Tag(name = "代码生成")
@RequestMapping("/gen/generator")
@RequiredArgsConstructor
public class GeneratorController {

    final GeneratorService generatorService;

    @PostMapping
    @Operation(summary = "执行")
    public R<List<GenResultVo>> generatorNew(@RequestBody NewGeneratorDTO module) {
        log.info("module:{}", module);
        return R.ok(generatorService.genFiles(module));
    }

}
